package com.gxc;

import com.gxc.aop.AnnotationService;
import com.gxc.aop.MethodService;
import com.gxc.config.AopConfig;
import com.gxc.my.MyService;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

/**
 * 启动类.
 *
 * @author 宫新程
 * @since 2018/12/14 11:31 AM
 */
public class Application {

  /** Main. */
  public static void main(String[] args) throws InterruptedException {
    // 初始化Spring容器
    AnnotationConfigApplicationContext context =
        new AnnotationConfigApplicationContext(AopConfig.class);

    // 实例化Bean
    AnnotationService annotationService = context.getBean(AnnotationService.class);
    MethodService methodService = context.getBean(MethodService.class);
    MyService bean = context.getBean(MyService.class);

    annotationService.add();
    System.out.println("---------------");
    methodService.add();
    System.out.println("---------------");
    bean.test1();
    System.out.println("---------------");
    bean.test2();

    Thread.sleep(500);
    context.close();
  }
}
